from django.urls import path
from . import views

urlpatterns = [
    # 数据源管理
    path('datasources/', views.DataSourceListView.as_view(), name='datasource_list'),
    path('datasources/add/', views.DataSourceCreateView.as_view(), name='datasource_create'),
    path('datasources/<int:pk>/edit/', views.DataSourceUpdateView.as_view(), name='datasource_update'),
    path('datasources/<int:pk>/delete/', views.DataSourceDeleteView.as_view(), name='datasource_delete'),
    path('datasources/<int:pk>/test/', views.test_datasource_connection, name='datasource_test'),
    
    # OPC UA订阅
    path('opcua/list/', views.OPCUASubscriptionListView.as_view(), name='opcua_subscription_list'),
    path('opcua/add/', views.OPCUASubscriptionCreateView.as_view(), name='opcua_subscription_add'),
    path('opcua/<int:pk>/edit/', views.OPCUASubscriptionUpdateView.as_view(), name='opcua_subscription_edit'),
    path('opcua/<int:pk>/delete/', views.OPCUASubscriptionDeleteView.as_view(), name='opcua_subscription_delete'),
    path('opcua/<int:pk>/toggle/', views.toggle_opcua_subscription, name='opcua_subscription_toggle'),
    
    # MQTT订阅
    path('mqtt/list/', views.MQTTSubscriptionListView.as_view(), name='mqtt_subscription_list'),
    path('mqtt/add/', views.MQTTSubscriptionCreateView.as_view(), name='mqtt_subscription_add'),
    path('mqtt/<int:pk>/edit/', views.MQTTSubscriptionUpdateView.as_view(), name='mqtt_subscription_edit'),
    path('mqtt/<int:pk>/delete/', views.MQTTSubscriptionDeleteView.as_view(), name='mqtt_subscription_delete'),
    path('mqtt/<int:pk>/toggle/', views.toggle_mqtt_subscription, name='mqtt_subscription_toggle'),
    path('mqtt-item/<int:item_id>/toggle/', views.toggle_mqtt_item, name='mqtt_item_toggle'),

    # API接口
    path('api/datasources/', views.DataSourceViewSet.as_view({'get': 'list'}), name='api_datasource_list'),
    path('api/opcua-subscriptions/', views.OPCUASubscriptionViewSet.as_view({'get': 'list'}), name='api_opcua_subscription_list'),
    path('api/mqtt-subscriptions/', views.MQTTSubscriptionViewSet.as_view({'get': 'list'}), name='api_mqtt_subscription_list'),

    # 仪表板
    path('dashboard/', views.subscription_dashboard, name='subscription_dashboard'),
] 